package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.mapper.TbIncomMapper;
import com.bwie.pojo.TbCar;
import com.bwie.pojo.TbIncom;
import com.bwie.service.TbCarService;
import com.bwie.mapper.TbCarMapper;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author HUAWEI
* @description 针对表【tb_car】的数据库操作Service实现
* @createDate 2025-05-13 09:21:14
*/
@Service
public class TbCarServiceImpl extends ServiceImpl<TbCarMapper, TbCar>
    implements TbCarService{
    @Autowired
    private TbCarMapper tbCarMapper;
    @Autowired
    private TbIncomMapper tbIncomMapper;

    @Override
    public R inCome(TbCar tbCar) {

        return R.OK(tbCarMapper.insert(tbCar));
    }

    @Override
    public R getCarList(PageInfoVo pageInfoVo) {
        Page<TbCar> page = new Page<>(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());
        LambdaQueryWrapper<TbCar> wrapper = new LambdaQueryWrapper<>();
        if(!StringUtils.isBlank(pageInfoVo.getCarCode())){
            wrapper.like(TbCar::getCarCode,pageInfoVo.getCarCode());
        }
        if(pageInfoVo.getBeginTime()!=null && pageInfoVo.getEndTime()!=null){
            wrapper.ge(TbCar::getCominTime,pageInfoVo.getBeginTime()).le(TbCar::getCominTime,pageInfoVo.getEndTime());
        }
        Page<TbCar> tbCarPage = tbCarMapper.selectPage(page, wrapper);
        return R.OK(tbCarPage);
    }


}




